package com.wt.controller;

import com.wt.common.ResultData;
import com.wt.entities.Account;
import com.wt.entities.Role;
import com.wt.mapper.AccountMapper;
import com.wt.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created with IDEA
 * Describe:
 * Author:tianji
 * Date:2018/11/1
 * Time:19:22
 */
@Controller
public class RoleController {
    @Autowired
    private RoleMapper roleMapper;

    @RequestMapping("/getAllRole")
    @ResponseBody
    public ResultData getAllRole(){
        List<Role> roles = roleMapper.getAllRole();
        return ResultData.build(0,"success",roles);
    }

    @RequestMapping("/getRoleById")
    @ResponseBody
    public ResultData getAccountById(String id){
        Role role = roleMapper.getRoleById(id);
        return ResultData.build(0,"success",role);
    }

    @RequestMapping("/delRoleById")
    @ResponseBody
    public ResultData deleteAccount(String id){
        int i = roleMapper.deleteRole(id);
        return ResultData.build(0,"success",i);
    }

    @RequestMapping("/insertRole")
    @ResponseBody
    public ResultData insertAccount(Role role){
        int i = roleMapper.insertRole(role);
        return ResultData.build(0,"success",role);
    }
}
